class Solution {
    public int lengthOfLIS(int[] nums) {
        int[] f = new int[nums.length];
        Arrays.fill(f, 1);
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[j] < nums[i]) {
                    f[i] = Math.max(f[i], f[j] + 1);
                }
            }
        }
        return Arrays.stream(f).boxed().max(Comparator.comparingInt(i -> i)).orElse(1);
    }
}
